use crate::msg::*;
pub struct MsgError {
src_msg: WndMsg,
source: Box<dyn std::error::Error + Send + Sync>,
}
impl std::error::Error for MsgError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
Some(self.source.as_ref())
}
}
impl std::fmt::Display for MsgError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "WM {} - {}",
self.src_msg.msg_id, self.source.to_string())
}
}
impl std::fmt::Debug for MsgError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self, f)
}
}
impl MsgError {
#[must_use]
pub const fn new(
src_msg: WndMsg,
source: Box<dyn std::error::Error + Send + Sync>,
) -> MsgError
{
Self { src_msg, source }
}
#[must_use]
pub const fn src_msg(&self) -> WndMsg {
self.src_msg
}
}